package com.guoxin.chapter7;

/**
 * @author guoxin
 * @date 2019/9/24
 */
public class DeadLoopClassTest {

    public static void main(String[] args) {
        Runnable script = new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread() + " start");
                DeadLoopClass dlc = new DeadLoopClass();
                System.out.println(Thread.currentThread() + " run over");
            }
        };

        Thread thread1 = new Thread(script);
        Thread thread2 = new Thread(script);
        thread1.start();
        thread2.start();
    }

    static class DeadLoopClass{
        static {
            //如果不加这个if语句，编译器将提示“Initializer must be able to complete normally”并拒绝编译
            if (true) {
                System.out.println(Thread.currentThread() + " init DeepLoopClass");
                while (true) {

                }
            }
        }
    }
}
